<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>算法测试页</title>
</head>
<body>
    <h1>算法测试</h1>
    <div id="myDiv"><h2>通过 AJAX 改变文本</h2></div>
    <button id="b01" type="button">改变内容</button>
</body>
<script type="text/javascript" src="./jquery/jquery-3.6.0.js"></script>
<script type="text/javascript" src="./common/sm4.js"></script>
<script type="text/javascript">
    var root = "/algorithm";
    $(document).ready(function(){
        $("#b01").click(function(){
            var str = "前端传入的SM4加密的内容";
            var s4 = new SM4Util();
            var text = s4.encryptData_ECB(str);
            $.ajax({
                url : root + "/test/getStr",
                method:"get",
                data : {"str" : text},
                success : function (data) {
                    $("#myDiv").html(s4.decryptData_ECB(data));
                }
            });
        });
    });
</script>
</html>